package com.app.ui.popupview;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;

import com.wxj.zx.R;


/**
 * Created by junfengwang on 2017/1/5.
 */

public class OptionPhotoPopupView extends CustomPopupWindow implements View.OnClickListener {


    public OptionPhotoPopupView(Activity activity) {
        super(activity);
    }

    @Override
    protected void onCreate() {
        setPopupWindowView(R.layout.popupview_option_photo);
        findViewById(R.id.camera_tv).setOnClickListener(this);
        findViewById(R.id.photo_tv).setOnClickListener(this);
        findViewById(R.id.cancel_tv).setOnClickListener(this);
    }
    public void setTitleText(String title) {
        ((TextView) findViewById(R.id.title_tv)).setText(title);
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.photo_tv:
                if (onPhotoListener == null) {
                    break;
                }
                onPhotoListener.onPhotoChoose();
                break;
            case R.id.camera_tv:
                if (onPhotoListener == null) {
                    break;
                }
                onPhotoListener.onPhotoTake();
                break;
            case R.id.cancel_tv:
                if (onPhotoListener == null) {
                    break;
                }
                onPhotoListener.onPhotoCancel();
                break;
        }
        dismiss();
    }



    private OnPhotoListener onPhotoListener;

    public void setOnPhotoListener(OnPhotoListener onPhotoListener) {
        this.onPhotoListener = onPhotoListener;
    }


    /**
     * Dialog按钮回调接口
     */
    public interface OnPhotoListener {

        void onPhotoChoose();//选择本地照片

        void onPhotoTake();//照相

        void onPhotoCancel();//取消

    }
}